﻿using System;
using System.Globalization;

namespace LBSoft.Common.DotNetExt
{
    public static class ExtDateTime
    {
        /// <summary>
        /// 判断是否是默认的时间
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static bool IsDefalutDateTime(this DateTime source)
        {
            return source == default(DateTime);
        }
        /// <summary>
        /// 获取中文星期
        /// </summary>
        /// <param name="source"></param>
        /// <param name="prefix">前缀，如果为null或string.Empty，则前缀默认为“星期”</param>
        /// <returns></returns>
        public static string GetWeekDayCn(this DateTime source, string prefix)
        {
            int weekDay = (int)source.DayOfWeek;
            return weekDay.ToWeekDayCn(prefix);
        }

        /// <summary>
        /// 获取中文月份
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static string GetMonthCn(this DateTime source)
        {
            ChineseLunisolarCalendar objCnCalendar = new ChineseLunisolarCalendar();
            int month = objCnCalendar.GetMonth(source);
            return month.ToMonthCn();
        }

        /// <summary>
        /// 获取中文日期
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static string GetDayCn(this DateTime source)
        {
            ChineseLunisolarCalendar objCnCalendar = new ChineseLunisolarCalendar();
            int day = objCnCalendar.GetDayOfMonth(source);
            return day.ToDayCn();
        }

    }
}
